<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>账户安全</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<link type="text/css" rel="stylesheet" href="statics/css/style.css" />

<script type="text/javascript" src="/EasyBuy/statics/js/menu.js"></script>
<script type="text/javascript" src="/EasyBuy/statics/js/select.js"></script>


<title>尤洪</title>
</head>
<body>
	<%@ include file="../../common/header.jsp" %>
	<%@ include file="../../common/backendHeader.jsp" %>
  	
  	<c:choose>
		<c:when test="${empty applicationScope.type }">
			<% 	request.getRequestDispatcher("../../UserServlet?opr=type&href=Member_Safe&href1=user").forward(request, response); %>
		</c:when>
		<c:otherwise>
			<c:if test="${applicationScope.type==1 }">
  				<%@ include file="../../common/sideMamber.jsp" %> 
			</c:if>
			<c:if test="${applicationScope.type==0 }">
				<%@ include file="../../common/sideUser.jsp" %> 
			</c:if>
		</c:otherwise>
	 </c:choose>
  	
  	
			<div class="m_right">
				<p></p>
				<div class="mem_tit">账户安全</div>
				<div class="m_des">
					<form>
						<table border="0" style="width:880px;" cellspacing="0"
							cellpadding="0">
							<tr height="45">
								<td width="80" align="right">原手机 &nbsp; &nbsp;</td>
								<td><input type="text" placeholder="请输入本账号原手机号"
									class="add_ipt" style="width:180px;" id="phone" />&nbsp; <font
									color="#ff4e00" id="phonediv">*</font>
								</td>
							</tr>
							<tr height="45">
								<td align="right">新手机 &nbsp; &nbsp;</td>
								<td><input type="text" placeholder="请输入新手机号"
									class="add_ipt" style="width:180px;" id="newphone" />&nbsp; <font
									color="#ff4e00" id="newphonediv">*</font>
								</td>
							</tr>
							<tr height="50">
								<td>&nbsp;</td>
								<td><input type="button" value="确认修改" class="btn_tj"
									id="sj" />
								</td>
							</tr>
						</table>
					</form>
				</div>

				<div class="m_des">
					<form>
						<table border="0" style="width:880px;" cellspacing="0"
							cellpadding="0">
							<tr height="45">
								<td width="80" align="right">原邮箱 &nbsp; &nbsp;</td>
								<td><input type="text" placeholder="请输入本账号原邮箱"
									class="add_ipt" style="width:180px;" id="email" />&nbsp; <font
									color="#ff4e00" id="emaildiv">*</font>
								</td>
							</tr>
							<tr height="45">
								<td align="right">新邮箱 &nbsp; &nbsp;</td>
								<td><input type="text" placeholder="请输入新邮箱" class="add_ipt"
									style="width:180px;" id="newemail" />&nbsp; <font
									color="#ff4e00" id="newemaildiv">*</font>
								</td>
							</tr>
							<tr height="50">
								<td>&nbsp;</td>
								<td><input type="button" value="确认修改" class="btn_tj"
									id="yx" />
								</td>
							</tr>
						</table>
					</form>
				</div>

				<div class="m_des">
					<form>
						<table border="0" style="width:880px; margin-left:-135px;" cellspacing="0"
							cellpadding="0">
							<tr height="45">
								<td width="80" align="right">原密码 &nbsp; &nbsp;</td>
								<td><input type="password" placeholder="请输入本账号原密码"
									class="add_ipt" style="width:180px;" id="pwd" />&nbsp; <font
									color="#ff4e00" id="pwddiv">*</font>
								</td>
							</tr>
							<tr height="45">
								<td align="right">新密码 &nbsp; &nbsp;</td>
								<td><input type="password" placeholder="请输入6-9位新密码"
									class="add_ipt" style="width:180px;" id="newpwd" />&nbsp; <font
									color="#ff4e00" id="newpwddiv">*</font>
								</td>
							</tr>
							<tr height="45">
								<td align="right">确认密码 &nbsp; &nbsp;</td>
								<td><input type="password" placeholder="请再次输入新密码"
									class="add_ipt" style="width:180px;" id="qpwd" />&nbsp; <font
									color="#ff4e00" id="qpwddiv">*</font>
								</td>
							</tr>
							<tr height="50">
								<td>&nbsp;</td>
								<td><input type="button" value="确认修改" class="btn_tj"
									id="mm" />
								</td>
							</tr>
						</table>
					</form>
				</div>
			</div>
		</div>
		<!--End 用户中心 End-->


		<script type="text/javascript"
			src="/EasyBuy/statics/js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
			$(".safe").attr("class","now");
					var password="";//密码
					var email="";	//邮箱
					var mobile="";//手机号
				function zhang(){
					//正则表达式
					var emaill = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/; //邮箱正则
					var phonee = /^0{0,1}(13[0-9]|15[0-9]|153|156|18[7-9])[0-9]{8}$/; //手机号正则
					//原手机号码验证
					$("#phone").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#phonediv").text("*原手机号码不能为空！");
						
						}else if(mobile!=$(this).val()){
							$("#phonediv").text("*原手机号码不对！");
						
						}else{
							$("#phonediv").text("*");
						}
					});	
					
					//现在手机号码验证
					$("#newphone").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#newphonediv").text("*现在手机号码不能为空！");
						
						}else if(phonee.test($(this).val())==false){
							$("#newphonediv").text("*现在手机号码格式不对！");
							
						}else{
							$("#newphonediv").text("*");
						}
					});
					
					
					//	原email验证
					
					$("#email").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#emaildiv").text("*原邮箱不能为空！");
							
						}else if(email!=$(this).val()){
							$("#emaildiv").text("*原邮箱输入不正确！");
						
						}else{
							$("#emaildiv").text("*");
						}
					});	
					
					//现在邮箱验证
					$("#newemail").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#newemaildiv").text("*现在邮箱不能为空！");
							
						}else if(emaill.test($(this).val())==false){
							$("#newemaildiv").text("*现在邮箱格式不对！");
						
						}else{
							$("#newemaildiv").text("*");
						}
					});
					
					//原密码验证
					$("#pwd").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#pwddiv").text("*原密码不能为空！");
						
						}else if($(this).val()!=password) {
							$("#pwddiv").text("*原密码输入不正确！");
						
						}else{
							$("#pwddiv").text("*");
						}
					});
					
					//现在密码验证
					$("#newpwd").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#newpwddiv").text("*现在密码不能为空！");
							
						}else{
							$("#newpwddiv").text("*");
						}
					});
					//第二次密码验证
					$("#qpwd").blur(function(){
						if ($(this).val() == ""|| $(this).val() == null) {
							$("#qpwddiv").text("*第二次密码不能为空");
						}else if ($(this).val()!=$("#newpwd").val()) {
							$("#qpwddiv").text("*两次密码不一致!");
						}else{
							$("#qpwddiv").text("*");
						}
					});
				}
				$.getJSON("UserServlet","opr=AnQuan",ballback);
				function ballback(data){
					password=data[0].password;
					email=data[0].email;
					mobile=data[0].mobile;
					zhang();
				}
				//修改手机号
				$("#sj").click(function(){
					if($("#phonediv").text()=="*"&&$("#newphonediv").text()=="*"&&$("#newphone").val()!=""&&$("#phone").val()!=""){
						$.get("UserServlet","opr=AnQuanXiu&userid=${applicationScope.id}&xsj="+$("#newphone").val(),function(data){
							alert(data);
							$("#phone").val("");
							$("#newphone").val("");
						});
					}
				});
				//修改邮箱
				$("#yx").click(function(){
					if($("#emaildiv").text()=="*"&&$("#newemaildiv").text()=="*"&&$("#newemail").val()!=""&&$("#email").val()!=""){
						$.get("UserServlet","opr=AnQuanYx&userid=${applicationScope.id}&yx="+$("#newemail").val(),function(data){
						alert(data);
						$("#email").val("");
						$("#newemail").val("");
					});
					}
				});
				//修改密码
				$("#mm").click(function(){
					if($("#pwddiv").text()=="*"&&$("#newpwddiv").text()=="*"&&$("#qpwddiv").text()=="*"&&$("#pwd").val()!=""&&$("#newpwd").val()!=""&&$("#qpwd").val()!=""){
						$.get("UserServlet","opr=AnQuanMm&userid=${applicationScope.id}&qpwd="+$("#qpwd").val(),function(data){
						alert(data);
						$("#pwd").val("");
						$("#newpwd").val("");
						$("#qpwd").val("");
					});
					}
				});
			});
		</script>
			
</body>
</html>